'use strict';

module.exports = () => {

  /*
   * 需要登录
   */
  return async function(ctx, next) {
    const {service} = this;
    if (!ctx.request.body.openid) {
      ctx.status = 403;
      ctx.body = {data:0,content:'forbidden!没有权限'};
      return;
    }else{
      const {openid}=ctx.request.body;
      let data = await service.user.getUserByid(openid);
      if(data.data!=1){
        ctx.status = 403;
        ctx.body = {data:0,content:'forbidden!没有权限'};
        return;
      }else{
        await next();
      }
    }
   
  };
};
